home *** CD-ROM | disk | FTP | other *** search
- Path: global.gc.net!sourcebbs!david.mohorn
- From: david.mohorn@sourcebbs.com (DAVID MOHORN)
- Newsgroups: comp.lang.c
- Subject: COLLEGE PROFESSORS! # 2/2
- Message-ID: <8BEC555.02C70031C4.uuout@sourcebbs.com>
- Date: Tue, 16 Apr 96 22:45:00 -0500
- Distribution: world
- Organization: SelectiveSourceBBS VirginiaBeach (804)471 6776
- Reply-To: david.mohorn@sourcebbs.com (DAVID MOHORN)
- X-Newsreader: PCBoard Version 15.22
- X-Mailer: PCBoard/UUOUT Version 1.20
-
- (Continued from previous message)
-
-
- return StatusSwitch
- *** end of validation routine ***
-
- Clearly, example 1 is inefficient and wastes processing time by
- continuing to check for valid data once an error is found and wasting
- another few CPU cycles making another comparison.
-
- Example 2 to me seems like the best approach by returning to the caller
- immediately once and error if found.
-
- Example 3 is almost as good as 2, since the nested-ifs will not continue
- to validate data once an error is found.
-
- The instructors philosophy is to make it more "readable" and keep it as
- structured as possible! As if structured programming was the only way
- to accomplish this task. He also stated that nested ifs make the code
- harder to read. He also stated that there is no arm in wasting a
- few milliseconds doing the extra conditions, since it won't be
- noticeable anyway.
-
- I retorted his remark and said it would on a multitasking system where
- every cycle counts! If I were validating 10,000 data items, example 1
- would take a considerable amount of time longer than example 2!
-
- Does anyone else have any opinions or horror stories?
-
- RIME: ->1369 FIDO: (1:275/102) INTERNET: david.mohorn@sourcebbs.com
-
- ---
- * QMPro 1.53 * Programming is 10% inspiration and 90% debugging.
-
-
- ---
- This message originated from: ---------- Selective Source BBS
- ------- Virginia Beach, Virginia
- ----- (804) 471 6776
-